package practise.alogrithm.hundredInterviewQuestions;

import practise.alogrithm.hundredInterviewQuestions.Utils.TreeBuilder;
import practise.alogrithm.hundredInterviewQuestions.Utils.TreeNode;

/**
 * Created by richard on 6/2/14.
 */
public class TreeResult {
    public static TreeNode createTreeNode(){
        int[] arrays = new int[]{5,4,2,3,0,7,1,0,0,0,0,0,0,0,12};
        return TreeBuilder.createTreeByArrayInWidth(arrays);
    }

    public static int testTreeSum(TreeNode treeNode){
        if (treeNode == null)
            return 0;
        return treeNode.getValue() + testTreeSum(treeNode.getRight()) - testTreeSum(treeNode.getLeft());

    }

    public static void main(String[] args){
        System.out.println("result:" + testTreeSum(createTreeNode()));
    }
}
